package com.edu.bean;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class MyDataSource implements BeanNameAware, InitializingBean, DisposableBean {
    private String username;
    private String password;
    private String url;
    private String driver;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        System.out.println("2 setter");
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }
    public void getConnection(){
        System.out.println("8.执行了业务方法");
    }

    public MyDataSource() {
        System.out.println("1.构造");
    }

    @Override
    public String toString() {
        return "MyDataSource{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", url='" + url + '\'' +
                ", driver='" + driver + '\'' +
                '}';
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("3.Aware 接口");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("5 初始化接口");
    }
    public static void MyInit(){
        System.out.println("6. 执行了自定义初始化");
    }
    public static void MyDispose(){
        System.out.println("10. 执行了自定义销毁");
    }
    @Override
    public void destroy() throws Exception {
        System.out.println("9. Disposable接口销毁方法");
    }
}
